package com.jcl.cloud.services.crawler.catchnew.factory;


import com.jcl.cloud.common.service.constant.TaskRouteEnum;
import com.jcl.cloud.services.crawler.catchnew.task.CatchNewHandler;
import com.jcl.cloud.services.crawler.catchnew.task.QcwyCatchNewHandler;
import com.jcl.cloud.services.crawler.catchnew.task.ZlzpCatchNewHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Service
public class CatchNewHandlerFactory {

    @Autowired
    private QcwyCatchNewHandler qcwyCatchNewHandler;

    @Autowired
    private ZlzpCatchNewHandler zlzpCatchNewHandler;

    private Map<TaskRouteEnum, CatchNewHandler> handlerRoute = new HashMap();

    @PostConstruct
    public void init() {
        this.handlerRoute.put(TaskRouteEnum.QCWY, this.qcwyCatchNewHandler);
        this.handlerRoute.put(TaskRouteEnum.ZLZP, this.zlzpCatchNewHandler);
    }



    public CatchNewHandler getHandler(TaskRouteEnum type) {
        return (CatchNewHandler)this.handlerRoute.get(type);
    }
}
